package com.probox.common.entity.domain.customer;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.probox.common.core.annotation.Excel;
import com.probox.common.core.text.Convert;
import com.probox.common.entity.utils.DictUtils;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;

import java.io.Serializable;
import java.util.Date;
import java.util.HashMap;

/**
 * 任务列对象 customer_task_info
 *
 * @author usoft
 * @date 2022-09-30
 */
@Data
@NoArgsConstructor
@Accessors(chain = true)
@TableName("customer_task_info")
public class CustomerTaskInfo implements Serializable {
    private static final long serialVersionUID = 1L;

    /**
     * 任务ID
     */
    //默认主键自增
    @TableId(value = "task_id", type = IdType.AUTO)
    private Long taskId;

    /**
     * 任务代码
     */
    @Excel(name = "任务代码")
    private String taskCode;

    public String getTaskCodeStr() {
        HashMap dictCacheMap = DictUtils.getDictCacheMap("sys_task");
        return Convert.toStr(dictCacheMap.get(taskCode));
    }

    /**
     * 任务名称
     */
    @Excel(name = "任务名称")
    private String taskName;

    @Excel(name = "任务页面")
    @TableField(exist = false)
    private String taskPage;

    /**
     * 任务详情(图文混排)
     */
    @Excel(name = "任务详情(图文混排)")
    private String taskDesc;

    /**
     * 任务icon
     */
    @Excel(name = "任务icon")
    private String taskIcon;

    /**
     * 开始时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Excel(name = "开始时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
    private Date startDate;

    /**
     * 结束时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
    @Excel(name = "结束时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
    private Date endDate;

    /**
     * 任务简介
     */
    @Excel(name = "任务简介")
    private String taskBrief;

    /**
     * 是否展示在小程序任务列表(1展示/0不展示)
     */
    @Excel(name = "是否展示在小程序任务列表(1展示/0不展示)")
    private String isShow;

    @TableField(exist = false)
    private Long completed;
    /**
     * 奖励菠萝派
     */
    @Excel(name = "奖励菠萝派")
    private Long score;

    /**
     * 奖励经验值
     */
    @Excel(name = "奖励经验值")
    private Long expValue;

    /**
     * 奖励服务项目
     */
    @Excel(name = "奖励服务项目")
    private Long serviceItemId;

    @TableField(exist = false)
    private String serviceItemName;
    /**
     * 奖励套餐ID
     */
    @Excel(name = "奖励套餐ID")
    private Long cardId;

    @TableField(exist = false)
    private String cardName;

    /**
     * 奖励优惠券ID
     */
    @Excel(name = "奖励优惠券ID")
    private Long couponId;

    @TableField(exist = false)
    private String couponName;
    /**
     * 奖励商品ID
     */
    @Excel(name = "奖励商品ID")
    private Long productId;

    @TableField(exist = false)
    private String producName;

    public Object getReward() {

        if (ObjectUtils.isNotEmpty(score))
            return "菠萝派：" + score;
        if (ObjectUtils.isNotEmpty(expValue))
            return "经验值：" + expValue;
        if (ObjectUtils.isNotEmpty(serviceItemId))
            return "服务项目：" + serviceItemName;
        if (ObjectUtils.isNotEmpty(cardId))
            return "套餐卡：" + cardName;
        if (ObjectUtils.isNotEmpty(couponId))
            return "优惠券：" + couponName;
        if (ObjectUtils.isNotEmpty(productId))
            return "商品：" + producName;
        return null;
    }

    /**
     * 显示顺序
     */
    @Excel(name = "显示顺序")
    private Long taskSort;


    /**
     * 数据状态（0-无效/1-有效）
     */
    @Excel(name = "数据状态", readConverterExp = "0=-无效/1-有效")
    private String dataStatus;

    /**
     * 创建人
     */
    @Excel(name = "创建人")
    private Long createUser;

    /**
     * 创建时间
     */
    private Date createTime;

    /**
     * 创建人名称
     */
    @Excel(name = "创建人名称")
    private String createName;

    /**
     * 修改人
     */
    @Excel(name = "修改人")
    private Long updateUser;

    /**
     * 修改时间
     */
    private Date updateTime;

    /**
     * 修改人名称
     */
    @Excel(name = "修改人名称")
    private String updateName;


}
